#include"sqlite3.hpp"
#include<assert.h>
#include<sqlite3.h>
int CallBack(void*arg,int col,char**result,char**filed_name)
{
    std::vector<std::string>* array=(std::vector<std::string>*)arg;
    array->push_back(result[0]);
    return 0;
}
int main()
{
    Sqlite sq("./test.db");
    //1、打开文件
    assert(sq.open());
    //2、创建表 不存在就创建   学生： 学号  姓名  年龄
    const char*sql="create table if not exists student(sn int primary key,name varchar(32),age int);";
    assert(sq.exec(sql,nullptr,nullptr));
    //3、完成增、删、改、查
    //const char*insert_sql="insert into student values(1,'小明',18),(2,'小黑',19),(3,'小红',20);";
    //const char*update_sql="update student set name='张小明' where sn=1;";
    // const char*delete_sql="delete from student where sn=3";
    // assert(sq.exec(delete_sql,nullptr,nullptr));
    std::vector<std::string> name;
    const char*select_sql="select name from student";

    assert(sq.exec(select_sql,CallBack,&name));
    for(auto e:name)
    {
        std::cout<<e<<std::endl;
    }
    sq.close();
    return 0;
}